﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace HeavenvsDarkness
{
    public static class UserInput
    {
        public static KeyboardState PrevKeyboardState;
        public static KeyboardState CurrentKeyboardState;
        static int counter = 0;

        public static int Counter
        {
            get { return counter; }
            set { counter = value; }
        }
        public static Boolean KeyClicked(Keys Key)
        {
            return PrevKeyboardState.IsKeyDown(Key) && CurrentKeyboardState.IsKeyUp(Key);
        }

        public static Boolean KeyPressed(Keys Key)
        {
            return CurrentKeyboardState.IsKeyDown(Key);
        }

        public static void ProcessUserInput()
        {

            if (KeyPressed(Keys.Left))
            {
                Global.BroastCastEvent(Global.EVENT.GM_LEFTARROW_PRESSED, null, null);
                return;
            }

            if (KeyPressed(Keys.Right))
            {
                Global.BroastCastEvent(Global.EVENT.GM_RIGHTARROW_PRESSED, null, null);
            }

            if (KeyClicked(Keys.Up))
            {
                Global.BroastCastEvent(Global.EVENT.GM_UPARROW_PRESSED, null, null);
            }

            if (KeyClicked(Keys.Down))
            {
                Global.BroastCastEvent(Global.EVENT.GM_DOWNARROW_PRESSED, null, null);
            }

            if (KeyClicked(Keys.Enter))
            {
                Global.BroastCastEvent(Global.EVENT.GM_ENTER_CLICKED, null, null);
            }

        }
    }

    
}
